/**
 * Project: TacticaPescaditos
 * File: Telegram.java
 */
package org.javahispano.javacup.tacticas_aceptadas.Pescaditos.com.chidotronics.javacup.messages;





/**
 * @author Carlos Alberto
 * class: Telegram
 */
public class Telegram {
	
	public enum MessageType{
		HELP_ME,
		PASS_TO_ME,
		RECEIVE_BALL,
		WAIT,
		CHANGE_STATE,
		RECALCULATE_RECEIVING_TARGET
	}


	private MessageType messageType;;
	
	private int receiver;
	
	private int sender;
	
	private int delay;

	private Object extraInfo;

	
	
	/**
	 * 
	 */
	public Telegram() {
		this.sender = -1;
		this.receiver = -1;
	}
	
	/**
	 * @param messageType
	 * @param sender
	 * @param receiver
	 * @param dispatchTime
	 * @param extraInfo
	 */
	public Telegram(MessageType messageType, int sender,
			int receiver,
			Object extraInfo) {
		this.messageType = messageType;
		this.sender = sender;
		this.receiver = receiver;
		this.extraInfo = extraInfo;
	}



	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		
		if (!(obj instanceof Telegram)) {
			return false;
		}
		
		Telegram t = (Telegram)obj;
		
		return ( this.sender == t.sender &&
				this.receiver == t.receiver &&
				this.messageType == t.messageType);
	}



	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return " sender"+this.sender+ 
			" receiver"+ this.receiver+ " message"+ messageType;
	}



	/**
	 * @return the messageType
	 */
	public MessageType getMessageType() {
		return messageType;
	}

	/**
	 * @return the extraInfo
	 */
	public Object getExtraInfo() {
		return extraInfo;
	}

	/**
	 * @return the receiver
	 */
	public int getReceiver() {
		return receiver;
	}

	/**
	 * @return the timeOfLife
	 */
	public int getDelay() {
		return --delay;
	}

	public void setDelay(int delay) {
		this.delay = delay;
	}


	
}
